var chart1; // globally available

function drawChart(chartTarget, title, x_title, x_start, x_step, countStr) {

	var options = {

			chart: {
				renderTo: chartTarget,
				defaultSeriesType: 'line',
				zoomType: 'xy'
			},
			credits: {
				enabled: false
			},
			title: {
				text: title,
			},
			xAxis: {
				title: {
					text: x_title
				}
			},
			plotOptions: {
		        series: {
		        	pointStart: x_start,
		        	pointInterval: x_step,
		            marker: {
		                enabled: false,
		                states: {
		                    hover: {
		                        enabled: true
		                    }
		                }
		            }
		        }
		    },
			yAxis: {
				title: {
					text: 'Count'
				},
				min: 0
			},
			tooltip: {
				formatter: function() {
					return x_title + ' = ' + this.x +'<br/>'+ 'count = ' + this.y;
				}
			},
			legend: {
				floating: false,
				borderWidth: 1
			},
			series: []
	};

	var lines = countStr.split(';');

	// Set labels and count data
	$.each(lines, function(lineNo, line) {
		var counts = line.split(',');
		var series = {
				data: []
		};
		$.each(counts, function(countNo, count) {
			if (countNo == 0) {
				series.name = count;
			} else {
				series.data.push(parseFloat(count));
			}
		});

		options.series.push(series);
	});

	// Create the chart
	var chart = new Highcharts.Chart(options);
};